<template>
  <div class="manager-main-left">
    <el-menu :default-active="currentPath"
             :default-openeds="['1', '2']"
             router
    >
      <el-menu-item index="/manager/home">
        <el-icon><House /></el-icon>
        <span>系统首页</span>
      </el-menu-item>
      <el-sub-menu index="1">
        <template #title>
          <el-icon><Setting /></el-icon>
          <span>信息管理</span>
        </template>
        <el-menu-item v-if="isAdmin" index="/manager/notice">系统公告</el-menu-item>
        <el-menu-item v-if="isAdmin" index="/manager/new">新闻资讯</el-menu-item>
        <el-menu-item v-if="isAdmin" index="/manager/examPlan">小测公告</el-menu-item>
      </el-sub-menu>
      <el-sub-menu index="2">
        <template #title>
          <el-icon><Watermelon /></el-icon>
          <span>植物信息管理</span>
        </template>
        <el-menu-item index="/manager/plantInfo">植物信息</el-menu-item>
        <el-menu-item index="/manager/plantClass">植物分类</el-menu-item>
        <el-menu-item index="/manager/plantGuide">植物指南</el-menu-item>
      </el-sub-menu>
      <el-sub-menu index="3">
        <template #title>
          <el-icon><Collection /></el-icon>
          <span>课程管理</span>
        </template>
        <el-menu-item v-if="isAdmin" index="/manager/questionType">题型信息</el-menu-item>
        <el-menu-item index="/manager/course">课程信息</el-menu-item>
        <el-menu-item index="/manager/question">题库信息</el-menu-item>
        <el-menu-item index="/manager/testPaper">小测信息</el-menu-item>
        <el-menu-item index="/manager/score">
          {{ isAdmin ? '成绩管理' : '阅卷打分'}}
        </el-menu-item>
      </el-sub-menu>
      <el-sub-menu index="4" v-if="isAdmin">
        <template #title>
          <el-icon><Comment /></el-icon>
          <span>论坛管理</span>
        </template>
        <el-menu-item index="/manager/share">文章分享</el-menu-item>
        <el-menu-item index="/manager/plantCircle">圈子管理</el-menu-item>
        <el-menu-item index="/manager/sensitiveWords">敏感词管理</el-menu-item>
        <el-menu-item index="/manager/plantMoment">动态管理</el-menu-item>
      </el-sub-menu>
      <el-sub-menu index="5" v-if="isAdmin">
        <template #title>
          <el-icon><Menu /></el-icon>
          <span>积分管理</span>
        </template>
        <el-menu-item index="/manager/pointsRule">积分规则管理</el-menu-item>
        <el-menu-item index="/manager/pointsGoods">积分商品管理</el-menu-item>
        <el-menu-item index="/manager/pointsOrder">积分商品订单管理</el-menu-item>
        <el-menu-item index="/manager/pointsTransaction">积分流水记录</el-menu-item>
      </el-sub-menu>
      <el-sub-menu index="6" v-if="isAdmin">
        <template #title>
          <el-icon><User /></el-icon>
          <span>用户管理</span>
        </template>
        <el-menu-item index="/manager/admin">管理员信息</el-menu-item>
        <!-- todo 考虑以后引个专家功能 2025/3/11 -->
<!--        <el-menu-item index="/manager/teacher">教师信息</el-menu-item>-->
        <el-menu-item index="/manager/user">普通用户信息</el-menu-item>
      </el-sub-menu>
    </el-menu>
  </div>
</template>

<script setup>
import { computed } from "vue";
import router from "@/router/index.js";
import {HomeFilled, Menu, Collection, Watermelon, User, Setting, House, Comment} from "@element-plus/icons-vue";

const currentPath = computed(() => router.currentRoute.value.path);
const isAdmin = computed(() => JSON.parse(localStorage.getItem('user') || '{}').role === 'ADMIN');
</script>

<style scoped>
.manager-main-left {
  width: 200px;
  height: calc(100vh - 60px); /* Adjust based on your header height */
  position: fixed;
  top: 60px; /* Match the header height */
  left: 0;
  background-color: #f7f7f7;
  overflow-y: auto;
}
</style>



